package leetcode;

import java.util.PriorityQueue;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2021-12-02 00:10
 **/
public class LeetCode506 {

    public String[] findRelativeRanks(int[] score) {
        PriorityQueue<int[]> queue = new PriorityQueue<>((x, y) -> y[0] - x[0]);
        int len = score.length;
        for (int i = 0; i < len; i++) {
            queue.offer(new int[]{score[i], i});
        }

        String[] strs = new String[len];
        int count = 0;
        while (!queue.isEmpty()) {
            int[] temp = queue.poll();
            if (count == 0) {
                strs[temp[1]] = "Gold Medal";
                count++;
            } else if (count == 1) {
                strs[temp[1]] = "Silver Medal";
                count++;
            } else if (count == 2) {
                strs[temp[1]] = "Bronze Medal";
                count++;
            } else {
                count++;
                strs[temp[1]] = "" + count;
            }
        }

        return strs;
    }

}
